home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcr / pcr4_4.lha / DIST / debugnub / CirioNubLocalProcs.c < prev    next >
C/C++ Source or Header  |  1992-04-16  |  7KB  |  339 lines

  1. /* begincopyright
  2.   Copyright (c) 1988-1990 Xerox Corporation. All rights reserved.
  3.   Use and copying of this software and preparation of derivative works based
  4.   upon this software are permitted. Any distribution of this software or
  5.   derivative works must comply with all applicable United States export
  6.   control laws. This software is made available AS IS, and Xerox Corporation
  7.   makes no warranty about the software, its performance or its conformity to
  8.   any specification. Any person obtaining a copy of this software is requested
  9.   to send their name and post office or electronic mail address to:
  10.     PCR Coordinator
  11.     Xerox PARC
  12.     3333 Coyote Hill Rd.
  13.     Palo Alto, CA 94304
  14.   endcopyright */
  15.  
  16. /*
  17.  * CirioNubLocalProcs.c
  18.  *
  19.  * Demers, November 5, 1990 9:14:40 am PST
  20.  */
  21.  
  22. #include "xr/Errno.h"
  23. #include "xr/Threads.h"
  24. #include "xr/ThreadsBackdoor.h"
  25. #include "xr/IncrementalLoad.h"
  26. #include "xr/CirioNubLocalProcs.h"
  27. #include "xr/CirioNubInnerProcs.h"
  28.  
  29.  
  30. static bool CirioNubLocal_ignoreLockFailure = FALSE;
  31.  
  32. void
  33. CirioNubLocalSetIgnoreLockFailure(ignore)
  34.     bool ignore;
  35. {
  36.     CirioNubLocal_ignoreLockFailure = ignore;
  37. }
  38.  
  39. bool
  40. CirioNubLocalGetIgnoreLockFailure()
  41. {
  42.     return CirioNubLocal_ignoreLockFailure;
  43. }
  44.  
  45.  
  46. static int
  47. CirioNubLocalLock(gotLockP)
  48.     bool *gotLockP;
  49. {
  50.     XR_ILError ile;
  51.     int i;
  52.  
  53.     ile = XR_LockIncrementalLoadState(FALSE);
  54.     if( ile == NIL ) {
  55.         *gotLockP = TRUE;
  56.         return 0;
  57.     } else {
  58.         *gotLockP = FALSE;
  59.         return ((CirioNubLocal_ignoreLockFailure) ? 0 : (-1));
  60.     }
  61. }
  62.  
  63.  
  64. #define DCLLOCK        bool gotLock
  65. #define LOCK()        { if(CirioNubLocalLock(&gotLock) != 0) return(-1); }
  66. #define UNLOCK()    { if(gotLock) (void)XR_UnlockIncrementalLoadState(); }
  67.  
  68.  
  69.  
  70. unsigned
  71. CirioNubLocalNull(desiredVersion)
  72.     unsigned desiredVersion;
  73. {
  74.     if( desiredVersion < CIRIO_NUB_LOCAL_PROCS_LOW_VERSION )
  75.         return CIRIO_NUB_LOCAL_PROCS_LOW_VERSION;
  76.     if( desiredVersion > CIRIO_NUB_LOCAL_PROCS_VERSION )
  77.         return CIRIO_NUB_LOCAL_PROCS_VERSION;
  78.     return desiredVersion;
  79. }
  80.  
  81.  
  82. int
  83. CirioNubLocalGetThread(index, buf)
  84.     int index;
  85.     CirioNubThreadData buf;
  86. {
  87.     return CirioNubInnerGetThread(index, buf);
  88. }
  89.  
  90.  
  91.  
  92. int
  93. CirioNubLocalPCtoInfo(pc, buf)
  94.     XR_Pointer pc;
  95.     CirioNubPCInfo buf;
  96. {
  97.     int ans;
  98.     DCLLOCK;
  99.     
  100.     LOCK();
  101.     ans = CirioNubInnerPCtoInfo(pc, buf);
  102.     UNLOCK();
  103.     return ans;
  104. }
  105.  
  106.  
  107.  
  108. int
  109. CirioNubLocalGetFileEntry(seqNum, buf)
  110.     unsigned seqNum;
  111.     CirioNubFileEntry buf;
  112. {
  113.     int ans;
  114.     DCLLOCK;
  115.  
  116.     LOCK();
  117.     ans = CirioNubInnerGetFileEntry(seqNum, buf);
  118.     UNLOCK();
  119.     return ans;
  120. }
  121.  
  122.  
  123. int
  124. CirioNubLocalGetMatchingSymEntryByName(
  125.     symID, pattern, caseSensitive, wantedTypes, ignoredClasses,
  126.     numToSkip, buf
  127. )
  128.     unsigned symID;
  129.     char *pattern;
  130.     bool caseSensitive;
  131.     unsigned wantedTypes;
  132.     unsigned ignoredClasses;
  133.     int numToSkip;
  134.     CirioNubSymEntry buf;
  135. {
  136.     int ans;
  137.     DCLLOCK;
  138.  
  139.     LOCK();
  140.     ans = CirioNubInnerGetMatchingSymEntryByName(
  141.             symID, pattern, caseSensitive,
  142.             wantedTypes, ignoredClasses, numToSkip, buf
  143.         );
  144.     UNLOCK();
  145.     return ans;
  146. }
  147.  
  148.  
  149. int
  150. CirioNubLocalGetMatchingSymEntryByValue(
  151.     symID, val, wantedTypes, ignoredClasses, numToSkip, buf
  152. )
  153.     unsigned symID;
  154.     unsigned val;
  155.     unsigned wantedTypes;
  156.     unsigned ignoredClasses;
  157.     int numToSkip;
  158.     CirioNubSymEntry buf;
  159. {
  160.     int ans;
  161.     DCLLOCK;
  162.  
  163.     LOCK();
  164.     ans = CirioNubInnerGetMatchingSymEntryByValue(
  165.             symID, val, wantedTypes, ignoredClasses, numToSkip, buf
  166.         );
  167.     UNLOCK();
  168.     return ans;
  169. }
  170.  
  171.  
  172. int
  173. CirioNubLocalReplacePatchArea(pc, newPatchArea, newSize)
  174.     XR_Pointer pc;
  175.     XR_Pointer newPatchArea;
  176.     unsigned long newSize;
  177. {
  178.     int ans;
  179.     struct CirioNubPCInfoRep pcir;
  180.     XR_ILFileEntry ilfe;
  181.     DCLLOCK;
  182.  
  183.     if( newPatchArea == NIL ) {
  184.         newPatchArea = XR_calloc(1, newSize);
  185.         if( newPatchArea == NIL ) return (-ENOMEM);
  186.     }
  187.     LOCK();
  188.     ans = CirioNubInnerPCtoInfo(pc, &pcir);
  189.     if( ans >= 0 ) {
  190.         ilfe = NIL;
  191.         for(;;) {
  192.             ilfe = XR_ILGetPrevFileEntry(ilfe);
  193.             if( ilfe == NIL ) {
  194.                 ans = -EINVAL;
  195.                 break;
  196.             }
  197.             if( ilfe->ilfe_seqNum == pcir.fileSeqNum ) {
  198.                 ilfe->ilfe_pAddr = ((caddr_t)(newPatchArea));
  199.                 ilfe->ilfe_pBytes = newSize;
  200.                 ans = 0;
  201.                 break;
  202.             }
  203.         }
  204.     }
  205.     UNLOCK();
  206.     return ans;
  207. }
  208.  
  209.  
  210. /* OBSOLETE: */
  211.  
  212. int
  213. CirioNubLocalLookupSymEntryByName(
  214.         sym, caseSensitive, externOnly, numToSkip, buf)
  215.     char *sym;
  216.     bool caseSensitive;
  217.     bool externOnly;
  218.     int numToSkip;
  219.     CirioNubSymEntry buf;
  220. {
  221.     int ans;
  222.     DCLLOCK;
  223.  
  224.     LOCK();
  225.     ans = CirioNubInnerGetMatchingSymEntryByName (
  226.             NIL, sym, caseSensitive, WANT_ALL_TYPES,
  227.             (externOnly ? IGNORE_INTERNAL : IGNORE_NONE),
  228.             numToSkip, buf
  229.     );
  230.     UNLOCK();
  231.     return ans;
  232. }
  233.  
  234. int
  235. CirioNubLocalSkipSymEntryByName(
  236.         symID, caseSensitive, externOnly, numToSkip, buf)
  237.     unsigned symID;
  238.     bool caseSensitive;
  239.     bool externOnly;
  240.     int numToSkip;
  241.     CirioNubSymEntry buf;
  242. {
  243.     int ans;
  244.     DCLLOCK;
  245.  
  246.     LOCK();
  247.     ans = CirioNubInnerGetMatchingSymEntryByName (
  248.             symID, NIL, caseSensitive, WANT_ALL_TYPES,
  249.             (externOnly ? IGNORE_INTERNAL : IGNORE_NONE),
  250.             numToSkip, buf
  251.     );
  252.     UNLOCK();
  253.     return ans;
  254. }
  255.  
  256.  
  257. int
  258. CirioNubLocalLookupSymEntryByValue(val, numToSkip, buf)
  259.     unsigned val;
  260.     int numToSkip;
  261.     CirioNubSymEntry buf;
  262. {
  263.     int ans;
  264.     DCLLOCK;
  265.  
  266.     LOCK();
  267.     ans = CirioNubInnerGetMatchingSymEntryByValue (
  268.             NIL, val, WANT_ALL_TYPES, IGNORE_NONE, numToSkip, buf
  269.     );
  270.     UNLOCK();
  271.     return ans;
  272. }
  273.  
  274.  
  275. int
  276. CirioNubLocalSkipSymEntryByValue(symID, numToSkip, buf)
  277.     unsigned symID;
  278.     int numToSkip;
  279.     CirioNubSymEntry buf;
  280. {
  281.     int ans;
  282.     DCLLOCK;
  283.  
  284.     LOCK();
  285.     ans = CirioNubInnerGetMatchingSymEntryByValue (
  286.             symID, 0, WANT_ALL_TYPES, IGNORE_NONE, numToSkip, buf
  287.     );
  288.     UNLOCK();
  289.     return ans;
  290. }
  291.  
  292. int
  293. CirioNubLocalLookupSymEntryByID(symID, buf)
  294.     unsigned symID;
  295.     CirioNubSymEntry buf;
  296. {
  297.     return CirioNubLocalSkipSymEntryByValue( symID, 0, buf );
  298. }
  299.  
  300. int
  301. CirioNubLocalGetMaxThreads()
  302. {
  303.     return XR_maxThreads;
  304. }
  305.  
  306. int
  307. CirioNubLocalGetThreadIndex(ct)
  308.     XR_CT ct;
  309. {
  310.     int ans;
  311.  
  312.     if( (ans = XR_ValidateCT(ct)) < 0 ) return ans;
  313.     return ct->ct_thread->t_index;
  314. }
  315.  
  316.  
  317.  
  318. /*
  319.  * Get stuff from XR_JmpBuf
  320.  *
  321.  * This is not included in CirioNubLocalProcs.h
  322.  */
  323.  
  324. XR_Pointer
  325. CirioNubLocalSPFromJmpBuf(b)
  326.     XR_JmpBuf b;
  327. {
  328.     return( XR_SP_FROM_JMP_BUF(b) );
  329. }
  330.  
  331.  
  332. XR_Pointer
  333. CirioNubLocalPCFromJmpBuf(b)
  334.     XR_JmpBuf b;
  335. {
  336.     return( XR_PC_FROM_JMP_BUF(b) );
  337. }
  338.  
  339.